package j2024.j202407;

import java.util.HashSet;
import java.util.Scanner;

public class j0727 {
    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        String a = in.nextLine();
        String b = in.nextLine();
        HashSet<Character> set = new HashSet<>();
        for (int i = 0; i < b.length(); i++) {
            set.add(b.charAt(i));
        }
        StringBuilder ret = new StringBuilder();
        for (int i = 0; i < a.length(); i++) {
            if(set.contains(a.charAt(i))){
                continue;
            }
            ret.append(a.charAt(i));
        }
        System.out.println(ret.toString());
    }

    public ListNode FindFirstCommonNode(ListNode pHead1, ListNode pHead2) {
        if(pHead2 == null || pHead1==null){
            return null;
        }
        int len1 = 0,len2 = 0;
        ListNode p1 = pHead1;
        ListNode p2 = pHead2;
        while(p1!=null){
            len1++;
            p1 = p1.next;
        }
        while(p2!=null){
            len2++;
            p2= p2.next;
        }
        p1 = pHead1;
        p2 = pHead2;
        if(len1>len2){
            for (int i = 0; i < len1-len2; i++) {
                p1 = p1.next;
            }
        }else {
            for (int i = 0; i < len2-len1; i++) {
                p2 = p2.next;
            }
        }
        while(p1!=null){
            if(p1.val == p2.val){
                return p1;
            }else {
                p1 = p1.next;
                p2 = p2.next;
            }
        }
        return null;
    }

    public static void mainw(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        String s = in.next();
        long[] a = new long[3];
        for (int i = 0; i < n; i++) {
            if(s.charAt(i)=='s'){
                a[0]++;
            }else if(s.charAt(i)=='h'){
                a[1]+=a[0];
            }else if(s.charAt(i)=='y'){
                a[2]+=a[1];
            }
        }
        System.out.println(a[2]);
    }

    /**
     * 1658. 将 x 减到 0 的最小操作数
     * @param nums
     * @param x
     * @return
     */
    public int minOperations(int[] nums, int x) {
        int n = nums.length;
        int sum = 0;
        for (int i = 0; i < n; i++) {
            sum+=nums[i];
        }
        int target = sum-x;
        if(target<0){
            return -1;
        }
        int l = 0,r = 0;
        int tmp = 0,max = -1;
        while(r<n){
            tmp+=nums[r];
            while(tmp>target){
                tmp-=nums[l++];
            }
            if(tmp == target){
                max = Math.max(max,r-l+1);
            }
            r++;
        }
        if(max==-1){
            return -1;
        }else {
            return n-max;
        }
    }
}
